﻿namespace MessengerSample
{
    using System;
    using System.Globalization;
    using System.Windows;
    using System.Windows.Data;

    using Microsoft.Live.Messenger;

    public class PresenceStatusToIconConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            PresenceStatus status = PresenceStatus.Offline;
            if (value is PresenceStatus)
            {
                status = (PresenceStatus)value;
            }

            switch (status)
            {
                case PresenceStatus.Online:
                    return "Assets/Online.png";
                case PresenceStatus.Away:
                case PresenceStatus.BeRightBack:
                case PresenceStatus.OutToLunch:
                case PresenceStatus.Idle:
                    return "Assets/Away.png";
                case PresenceStatus.Busy:
                case PresenceStatus.InACall:
                    return "Assets/Busy.png";
                case PresenceStatus.Offline:
                case PresenceStatus.AppearOffline:
                default:
                    return "Assets/Offline.png";
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }

        #endregion
    }
}